package com.sakiko.dailynote.config;

import com.github.pagehelper.PageInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

// 分页插件生效
@Configuration
public class MyBatisConfig {

    @Bean
    public PageInterceptor pageInterceptor() {
        PageInterceptor pageInterceptor = new PageInterceptor();
        Properties properties = new Properties();
        properties.setProperty("helperDialect", "mysql");
        properties.setProperty("reasonable", "true");
        pageInterceptor.setProperties(properties);
        return pageInterceptor;
    }
}

/*
 1. 检查MyBatis配置（后端需要确认）：
  <!-- MyBatis配置文件中必须有 -->
  <plugins>
      <plugin interceptor="com.github.pagehelper.PageInterceptor">
          <!-- 可以添加一些配置 -->
          <property name="helperDialect" value="mysql"/>
          <property name="reasonable" value="true"/>
      </plugin>
  </plugins>
 2. yaml中添加如下配置
    pagehelper:
        helper-dialect: mysql
        reasonable: true
 */